aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/(profile)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-06 20:33:45 -0800
committerAdam Soltys <[email protected]>2023-12-06 20:33:45 -0800
commit6b3ff247e4125941a611369ed9bb74a2ffca57d8 (patch)
tree91da939350398188834e5e002bc78011a2a8e5bf /src/routes/(app)/[username]/(profile)
parentbb59ac3e4e7fcbf7f8a48820eab0ee21558183fc (diff)
parentd69c34cf389639eac82d24d1f1b02f038ef42399 (diff)
downloadcoinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.tar.gz
coinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.zip
Merge branch 'master' into swapee
Diffstat (limited to 'src/routes/(app)/[username]/(profile)')
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.server.js36
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte356
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.server.js52
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte321
-rw-r--r--src/routes/(app)/[username]/(profile)/event/[id]/+page.server.js18
-rw-r--r--src/routes/(app)/[username]/(profile)/event/[id]/+page.svelte6
-rw-r--r--src/routes/(app)/[username]/(profile)/followers/+page.svelte81
-rw-r--r--src/routes/(app)/[username]/(profile)/follows/+page.svelte78
-rw-r--r--src/routes/(app)/[username]/(profile)/request/+page.server.js22
-rw-r--r--src/routes/(app)/[username]/(profile)/request/+page.svelte50
-rw-r--r--src/routes/(app)/[username]/(profile)/request/sent/+page.svelte21
11 files changed, 569 insertions, 472 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.server.js b/src/routes/(app)/[username]/(profile)/+layout.server.js
index f4f2ca0a..a508de92 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.server.js
+++ b/src/routes/(app)/[username]/(profile)/+layout.server.js
@@ -1,26 +1,26 @@
-import { get } from '$lib/utils';
+import { get } from "$lib/utils";
export async function load({ parent }) {
- let { subject, user } = await parent();
+ let { subject, user } = await parent();
- subject.follows = [];
- subject.followers = [];
+ subject.follows = [];
+ subject.followers = [];
- try {
- subject.follows = await get(`/${subject.pubkey}/follows`);
- } catch (e) {
- console.log('problem fetching follows', e);
- }
+ try {
+ subject.follows = await get(`/${subject.pubkey}/follows`);
+ } catch (e) {
+ console.log("problem fetching follows", e);
+ }
- try {
- subject.followers = await get(`/${subject.pubkey}/followers`);
- } catch (e) {
- console.log('problem fetching followers', e);
- }
+ try {
+ subject.followers = await get(`/${subject.pubkey}/followers`);
+ } catch (e) {
+ console.log("problem fetching followers", e);
+ }
- if (user) {
- user.follows = await get(`/${user.pubkey}/follows?tagsonly=true`);
- }
+ if (user) {
+ user.follows = await get(`/${user.pubkey}/follows?tagsonly=true`);
+ }
- return { subject, user };
+ return { subject, user };
}
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index b8059a90..32bebe3b 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -1,159 +1,247 @@
<script>
- import { f, s, sats } from '$lib/utils';
- import { animatedRate } from '$lib/store';
- import { Icon } from '$comp';
- import { t } from '$lib/translations';
- import { sign, send } from '$lib/nostr';
+ import { hexToUint8Array } from "uint8array-extras";
+ import { copy, f, s, sats } from "$lib/utils";
+ import Icon from "$comp/Icon.svelte";
+ import { t } from "$lib/translations";
+ import { sign, send } from "$lib/nostr";
+ import { bech32m } from "@scure/base";
+ import { page } from "$app/stores";
- export let data;
- let events, user, subject, rates, src, text;
- $: ({ events, user, rates, subject, src, text } = data);
- $: ({ currency, username: n, display } = subject);
+ export let data;
- $: username = n.length > 60 ? n.substr(0, 6) : display || n;
+ let { encode, toWords } = bech32m;
+ let events, user, subject, src, text;
let follow = async () => {
user.follows.push(['p', subject.pubkey, 'wss://nostr.swapee.me', subject.username]);
update();
};
- let unfollow = async () => {
- user.follows.splice(
- user.follows.findIndex((t) => t[1] === subject.pubkey),
- 1
- );
- update();
- };
+ $: username = n.length > 60 ? n.substr(0, 6) : display || n;
+ $: npub = bech32m.encode(
+ "npub",
+ toWords(hexToUint8Array(subject.pubkey)),
+ 180
+ );
+ $: lnaddr = `${n}@${$page.url.host}`;
+ $: profile = `${$page.url.host}/${n}`;
- let update = async () => {
- let event = {
- pubkey: user.pubkey,
- created_at: Math.floor(Date.now() / 1000),
- kind: 3,
- content: '',
- tags: user.follows
- };
+ let follow = async () => {
+ user.follows.push([
+ "p",
+ subject.pubkey,
+ "wss://nostr.swapee.me",
+ subject.username,
+ ]);
+ update();
+ };
- await sign({ event, user });
- await send(event);
+ let unfollow = async () => {
+ user.follows.splice(
+ user.follows.findIndex((t) => t[1] === subject.pubkey),
+ 1
+ );
+ update();
+ };
- user.follows = user.follows;
- };
+ let update = async () => {
+ let event = {
+ pubkey: user.pubkey,
+ created_at: Math.floor(Date.now() / 1000),
+ kind: 3,
+ content: "",
+ tags: user.follows,
+ };
+
+ await sign({ event, user });
+ await send(event);
- $: following = !!user?.follows.find((t) => t.includes(subject.pubkey));
+ user.follows = user.follows;
+ };
- let hideBio = true;
- let toggleBio = () => (hideBio = false);
+ $: following = !!user?.follows.find((t) => t.includes(subject.pubkey));
+
+ let showBio;
+ let toggleBio = () => (showBio = !showBio);
+
+ let showDetails;
+ let toggleDetails = () => (showDetails = !showDetails);
</script>
-<div class="container mx-auto w-full px-4 mb-4 flex flex-wrap lg:flex-nowrap space-y-5">
- <div class="hidden lg:block w-[240px] lg:mr-10" />
- <div class="w-[240px] lg:absolute space-y-5 left-20 mx-auto lg:mr-10">
- <h1 class="text-3xl font-bold text-center mx-auto">{display || username}</h1>
+<div class="container mx-auto w-full px-4 flex flex-wrap lg:flex-nowrap">
+ <div class="hidden lg:block lg:w-[300px]" />
+ <div class="lg:w-[300px] lg:absolute space-y-5 left-20 mx-auto max-w-sm">
+ <div
+ class="flex text-3xl font-bold text-center mx-auto justify-center gap-2"
+ >
+ <div class="my-auto">{display || username}</div>
+ <button on:click={toggleDetails}>
+ <Icon icon="stats" style="w-12" />
+ </button>
+ </div>
+
+ {#if showDetails}
+ <div>
+ <div class="font-bold">{$t("user.profilePage")}</div>
+ <div class="flex gap-4">
+ <div class="break-all grow text-secondary text-lg">
+ {profile}
+ </div>
+ <div class="flex mb-auto gap-1">
+ <button class="my-auto" on:click={() => copy(profile)}
+ ><Icon icon="copy" style="max-w-max min-w-[32px]" /></button
+ >
+ <a href={`/qr/${encodeURIComponent(profile)}`} class="my-auto">
+ <Icon icon="qr" style="invert max-w-max min-w-[32px]" />
+ </a>
+ </div>
+ </div>
+ </div>
+ <div>
+ <div class="font-bold">{$t("user.lightningAddress")}</div>
+ <div class="flex gap-4">
+ <div class="break-all grow text-secondary text-lg">
+ {lnaddr}
+ </div>
+ <div class="flex mb-auto gap-1">
+ <button class="my-auto" on:click={() => copy(lnaddr)}
+ ><Icon icon="copy" style="max-w-max min-w-[32px]" /></button
+ >
+ <a href={`/qr/${encodeURIComponent(lnaddr)}`} class="my-auto">
+ <Icon icon="qr" style="invert max-w-max min-w-[32px]" />
+ </a>
+ </div>
+ </div>
+ </div>
+ <div>
+ <div class="font-bold">{$t("user.nostrPubkey")}</div>
+ <div class="flex gap-4">
+ <div class="break-all grow text-secondary text-lg">
+ {npub}
+ </div>
+ <div class="flex my-auto gap-1">
+ <button class="my-auto" on:click={() => copy(npub)}
+ ><Icon icon="copy" style="max-w-max min-w-[32px]" /></button
+ >
+ <a href={`/qr/${encodeURIComponent(npub)}`} class="my-auto">
+ <Icon icon="qr" style="invert max-w-max min-w-[32px]" />
+ </a>
+ </div>
+ </div>
+ </div>
+ {/if}
- {#if subject.address}
- <div
- class="text-secondary mx-auto text-center lg:text-left lg:mx-0"
- class:line-clamp-3={hideBio}
- on:click={toggleBio}
- on:keydown={toggleBio}
- >
- {subject.address}
- </div>
- {/if}
+ {#if subject.address && subject.id !== user?.id}
+ <div
+ class="text-secondary mx-auto text-center lg:text-left lg:mx-0"
+ class:line-clamp-3={showBio}
+ on:click={toggleBio}
+ on:keydown={toggleBio}
+ >
+ {subject.address}
+ </div>
+ {/if}
- <div class="flex justify-around">
- <a href={`/${subject.pubkey}/follows`}
- ><b>{subject.follows.length}</b>
- <span class="text-secondary">{$t('user.following')}</span></a
- >
- <a href={`/${subject.pubkey}/followers`}
- ><b>{subject.followers.length}</b>
- <span class="text-secondary">{$t('user.followers')}</span></a
- >
- </div>
+ <div class="flex justify-center gap-2">
+ <a href={`/${subject.pubkey}/follows`}
+ ><b>{subject.follows.length}</b>
+ <span class="text-secondary">{$t("user.following")}</span></a
+ >
+ <a href={`/${subject.pubkey}/followers`}
+ ><b>{subject.followers.length}</b>
+ <span class="text-secondary">{$t("user.followers")}</span></a
+ >
+ </div>
- <div class="flex flex-wrap gap-2 w-full">
- {#if user && user.username !== subject.username && subject.pubkey}
- {#if following}
- <div class="w-full flex">
- <button
- class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60 bg-black text-white"
- on:click={unfollow}
- >
- <div class="mx-auto flex">
- <Icon icon={'profile'} style="my-auto h-6 mr-2 invert" />
- <div class="my-auto">{$t('user.following')}</div>
- </div>
- </button>
- </div>
- {:else}
- <div class="w-full flex">
- <button
- class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60"
- on:click={follow}
- >
- <div class="mx-auto flex">
- <Icon icon={'profile'} style="my-auto h-6 mr-2" />
- <div class="my-auto">{$t('user.follow')}</div>
- </div>
- </button>
- </div>
- {/if}
- {/if}
+ <div class="flex flex-wrap gap-2 w-full">
+ {#if user && user.username !== subject.username && subject.pubkey}
+ {#if following}
+ <div class="w-full flex">
+ <button
+ class="mx-auto rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60 bg-black text-white"
+ on:click={unfollow}
+ >
+ <div class="mx-auto flex">
+ <Icon icon={"profile"} style="my-auto h-6 mr-2 invert" />
+ <div class="my-auto">{$t("user.following")}</div>
+ </div>
+ </button>
+ </div>
+ {:else}
+ <div class="w-full flex">
+ <button
+ class="mx-auto rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60"
+ on:click={follow}
+ >
+ <div class="mx-auto flex">
+ <Icon icon={"profile"} style="my-auto h-6 mr-2" />
+ <div class="my-auto">{$t("user.follow")}</div>
+ </div>
+ </button>
+ </div>
+ {/if}
+ {/if}
- {#if !subject.anon && subject.username !== user?.username}
- <div class="w-full flex">
- <a
- href={user ? `/send/${subject.username}` : `/${subject.username}/receive`}
- class="mx-auto"
- >
- <button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
- <div class="mx-auto flex">
- <Icon icon="send" style="mr-2" />
- <div class="mt-1">{$t('user.pay')}</div>
- </div>
- </button>
- </a>
- </div>
- {/if}
+ {#if user && user.username !== subject.username && subject.pubkey}
+ <div class="w-full flex">
+ <a href={`/${subject.username}/messages`} class="mx-auto">
+ <button
+ class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60"
+ >
+ <div class="mx-auto flex">
+ <Icon icon="message" style="mr-2 my-auto" />
+ <div class="mt-1 my-auto">{$t("user.message")}</div>
+ </div>
+ </button>
+ </a>
+ </div>
+ {/if}
- {#if user && user.username !== subject.username && subject.pubkey}
- <div class="w-full flex">
- <a href={`/${subject.username}/messages`} class="mx-auto">
- <button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
- <div class="mx-auto flex">
- <Icon icon="support" style="mr-2 my-auto" />
- <div class="mt-1 my-auto">{$t('user.message')}</div>
- </div>
- </button>
- </a>
- </div>
- {/if}
- </div>
- </div>
+ {#if !subject.anon && subject.username !== user?.username}
+ <div class="w-full flex">
+ <a
+ href={user
+ ? `/send/${subject.username}`
+ : `/${subject.username}/receive`}
+ class="mx-auto"
+ >
+ <button
+ class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60"
+ >
+ <div class="mx-auto flex">
+ <Icon icon="send" style="mr-2" />
+ <div class="mt-1">{$t("user.pay")}</div>
+ </div>
+ </button>
+ </a>
+ </div>
+ {/if}
+ </div>
+ </div>
- <div class="w-full">
- <div class="mx-auto space-y-5 lg:max-w-lg xl:max-w-2xl">
- <slot />
- </div>
- </div>
+ <div class="w-full">
+ <div class="mx-auto space-y-5 lg:max-w-xl lg:pl-10 xl:max-w-2xl lg:pl-10">
+ <slot />
+ </div>
+ </div>
</div>
-{#if currency && !isNaN($animatedRate)}
- <div class="flex fixed w-full px-4 bg-white py-2 bottom-0 bg-opacity-90 tabular-nums">
- <div class="text-secondary flex mr-auto">
- <div class="flex mr-1">
- <div class="my-auto mr-1">1</div>
- <img src="/images/bitcoin.svg" class="w-5 my-auto" alt="Bitcoin" />
- </div>
- <div>= {f($animatedRate, currency)}</div>
- </div>
- <div class="text-secondary flex ml-auto">
- <div class="flex">
- <div class="mr-1">⚡️{s((1 * sats) / $animatedRate)} =</div>
- <div>{f(1, currency)}</div>
- </div>
- </div>
- </div>
+{#if currency}
+ <div
+ class="flex fixed w-full px-4 bg-white py-2 pb-3 bottom-0 bg-opacity-90 tabular-nums"
+ >
+ <div class="text-secondary flex mr-auto">
+ <div class="flex mr-1">
+ <div class="my-auto mr-1">1</div>
+ <img src="/images/bitcoin.svg" class="w-5 my-auto" alt="Bitcoin" />
+ </div>
+ <div>= {f(rates[currency], currency)}</div>
+ </div>
+ <div class="text-secondary flex ml-auto">
+ <div class="flex">
+ <div class="mr-1">⚡️{s((1 * sats) / rates[currency])} =</div>
+ <div>{f(1, currency)}</div>
+ </div>
+ </div>
+ </div>
{/if}
diff --git a/src/routes/(app)/[username]/(profile)/+page.server.js b/src/routes/(app)/[username]/(profile)/+page.server.js
index e37db1fe..3110ec40 100644
--- a/src/routes/(app)/[username]/(profile)/+page.server.js
+++ b/src/routes/(app)/[username]/(profile)/+page.server.js
@@ -1,35 +1,35 @@
-import { auth, get } from '$lib/utils';
+import { auth, get } from "$lib/utils";
export async function load({ cookies, params, parent, url }) {
- let { user, subject } = await parent();
- let { pubkey } = subject;
- let { since = 0 } = params;
+ let { user, subject } = await parent();
+ let { pubkey } = subject;
+ let { since = 0 } = params;
- let messages, invoices, sent, received, notes;
- messages = invoices = sent = received = notes = [];
+ let messages, invoices, sent, received, notes;
+ messages = invoices = sent = received = notes = [];
- if (pubkey) {
- if (user) {
- try {
- messages = await get(`/${user.pubkey}/${since}/messages`);
- messages = messages.sort((a, b) => b.created_at - a.created_at);
- } catch (e) {
- console.log(`failed to fetch nostr messages`, e);
- }
+ if (pubkey) {
+ if (user) {
+ try {
+ messages = await get(`/${user.pubkey}/${since}/messages`);
+ messages = messages.sort((a, b) => b.created_at - a.created_at);
+ } catch (e) {
+ console.log(`failed to fetch nostr messages`, e);
+ }
- ({ invoices, sent, received } = await get('/requests', auth(cookies)));
- }
+ ({ invoices, sent, received } = await get("/requests", auth(cookies)));
+ }
- try {
- notes = await get(`/${pubkey}/notes`);
- } catch (e) {
- console.log(`failed to fetch nostr notes for ${pubkey}`, e);
- }
+ try {
+ notes = await get(`/${pubkey}/notes`);
+ } catch (e) {
+ console.log(`failed to fetch nostr notes for ${pubkey}`, e);
+ }
- notes.map((e) => {
- e.seen = e.created_at;
- });
- }
+ notes.map((e) => {
+ e.seen = e.created_at;
+ });
+ }
- return { invoices, messages, notes, sent, received };
+ return { invoices, messages, notes, sent, received };
}
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index 8ff7ea90..376554b5 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -1,81 +1,69 @@
<script>
- import { onMount } from 'svelte';
- import { Icon, Avatar, Balance, Feed } from '$comp';
- import { t } from '$lib/translations';
- import { ease, f, sat, sats } from '$lib/utils';
- import { sign, send, encrypt, decrypt } from '$lib/nostr';
- import { event as e, password, rate, animatedRate } from '$lib/store';
- import { browser } from '$app/environment';
+ import { onMount } from "svelte";
+ import Icon from "$comp/Icon.svelte";
+ import Avatar from "$comp/Avatar.svelte";
+ import Balance from "$comp/Balance.svelte";
+ import Feed from "$comp/Feed.svelte";
+ import { t } from "$lib/translations";
+ import { ease, f, sat, sats } from "$lib/utils";
+ import { sign, send, encrypt, decrypt } from "$lib/nostr";
+ import { event as e, password } from "$lib/store";
+ import { browser } from "$app/environment";
- export let data;
- let { messages, notes, invoices, sent, received, subject, user, rates } = data;
- $: refresh(data);
- let refresh = (d) => ({ messages, notes, invoices, sent, received, subject, user, rates } = d);
+ export let data;
+ let { messages, notes, invoices, sent, received, subject, user, rates } =
+ data;
+ $: refresh(data);
+ let refresh = (d) =>
+ ({ messages, notes, invoices, sent, received, subject, user, rates } = d);
- let keys = new Set();
- let latest = [];
- let ready;
+ let keys = new Set();
+ let latest = [];
+ let ready;
- e.subscribe(async (event) => {
- if (!(event && ready)) return;
- if (event.recipient?.id === user.id && !~latest.findIndex((m) => m.id === event.id)) {
- event.content = await decrypt({ event, user });
+ e.subscribe(async (event) => {
+ if (!(event && ready)) return;
+ if (
+ event.recipient?.id === user.id &&
+ !~latest.findIndex((m) => m.id === event.id)
+ ) {
+ event.content = await decrypt({ event, user });
- let i = latest.findIndex((m) => m.pubkey === event.pubkey);
- let popped;
- if (~i) popped = latest.splice(i, 1);
- else popped = latest.pop();
+ let i = latest.findIndex((m) => m.pubkey === event.pubkey);
+ let popped;
+ if (~i) popped = latest.splice(i, 1);
+ else popped = latest.pop();
- latest.unshift(event);
- latest = latest;
- }
- });
+ latest.unshift(event);
+ latest = latest;
+ }
+ });
- $: initialize($password);
- let initialize = async (p) => {
- let i = 0;
- ready = false;
- if (!p || !user) return;
- while (i < messages.length) {
- let event = messages[i];
- i++;
+ $: initialize($password);
+ let initialize = async (p) => {
+ let i = 0;
+ ready = false;
+ if (!p || !user) return;
+ while (i < messages.length) {
+ let event = messages[i];
+ i++;
- if (!(event.author && event.recipient)) continue;
+ if (!(event.author && event.recipient)) continue;
- let k = event.author.id === user.id ? event.recipient?.pubkey : event.author.pubkey;
- if (!keys.has(k)) {
- keys.add(k);
- event.content = await decrypt({ event, user });
- if (event.content) latest.push(event);
- }
- }
+ let k =
+ event.author.id === user.id
+ ? event.recipient?.pubkey
+ : event.author.pubkey;
+ if (!keys.has(k)) {
+ keys.add(k);
+ event.content = await decrypt({ event, user });
+ if (event.content) latest.push(event);
+ }
+ }
- latest = latest;
- ready = true;
- };
-
- let i;
- let o;
-
- rate.subscribe((n) => {
- if (!user?.currency) return;
- clearInterval(i);
-
- let r = ((rates[user.currency] / rates['USD']) * n).toFixed(2);
-
- if (!r || isNaN(r)) return;
- if (!o) o = r;
-
- let t = 0;
- let d = o - r;
-
- i = setInterval(() => {
- if (!r) return;
- $animatedRate = (o - d * ease(t / 100)).toFixed(2);
- if (t > 80) (o = r) && clearInterval(i);
- t++;
- }, 10);
- });
+ latest = latest;
+ ready = true;
+ };
</script>
<div class="space-y-8">
@@ -103,6 +91,17 @@
</button>
</a>
+ <a href={`/send`} class="w-full md:w-60">
+ <button
+ class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-full"
+ >
+ <div class="mx-auto flex">
+ <Icon icon="send" style="my-auto h-6 mr-2" />
+ <div class="my-auto">{$t("user.dashboard.send")}</div>
+ </div>
+ </button>
+ </a>
+
<a href={`/buy`}>
<button
class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60 bg-black text-white"
@@ -125,99 +124,101 @@
</div>
{/if}
- {#if invoices.length}
- <div>
- <h1 class="text-secondary text-xl">Invoices</h1>
- {#each invoices as { amount, currency, rate, request: { requester, recipient }, hash }}
- {@const requested = user.username === requester?.username}
- <a href={`/${recipient.username}/invoice/${hash}` + (requested ? '/tip' : '')}>
- <div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
- <div class="flex gap-2">
- <div>
- {#if requested}
- <div class="flex">
- <Avatar user={recipient} size={20} />
- <div class="my-auto text-left">
- <p class="text-secondary">{$t('payments.invoiceFrom')}</p>
- <p class="ml-1 text-lg break-words">{recipient.username}</p>
- </div>
- </div>
- {:else}
- <div class="flex">
- <Avatar user={requester} size={20} />
- <div class="my-auto text-left">
- <p class="text-secondary">{$t('payments.awaiting')}</p>
- <p class="ml-1 text-lg break-words">{requester.username}</p>
- </div>
- </div>
- {/if}
- </div>
- <div class="whitespace-nowrap my-auto ml-auto flex gap-2">
- <div class="font-bold">
- {f(amount * (rate / sats), currency)}
- </div>
+ {#if invoices.length}
+ <div>
+ <h1 class="text-secondary text-xl">Invoices</h1>
+ {#each invoices as { amount, currency, rate, request: { requester, recipient }, hash }}
+ {@const requested = user.username === requester?.username}
+ <a
+ href={`/${recipient.username}/invoice/${hash}` +
+ (requested ? "/tip" : "")}
+ >
+ <div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
+ <div class="flex gap-2">
+ <div>
+ {#if requested}
+ <div class="flex">
+ <Avatar user={recipient} size={20} />
+ <div class="my-auto text-left">
+ <p class="text-secondary">{$t("payments.invoiceFrom")}</p>
+ <p class="ml-1 text-lg break-words">
+ {recipient.username}
+ </p>
+ </div>
+ </div>
+ {:else}
+ <div class="flex">
+ <Avatar user={requester} size={20} />
+ <div class="my-auto text-left">
+ <p class="text-secondary">{$t("payments.awaiting")}</p>
+ <p class="ml-1 text-lg break-words">
+ {requester.username}
+ </p>
+ </div>
+ </div>
+ {/if}
+ </div>
+ <div class="whitespace-nowrap my-auto ml-auto flex gap-2">
+ <div class="font-bold">
+ {f(amount * (rate / sats), currency)}
+ </div>
- <div class="text-secondary">{sat(amount)}</div>
- </div>
- </div>
- </div>
- </a>
- {/each}
- </div>
- {/if}
- {#if received.length}
- <div>
- <h1 class="text-secondary text-xl">Requests</h1>
+ <div class="text-secondary">{sat(amount)}</div>
+ </div>
+ </div>
+ </div>
+ </a>
+ {/each}
+ </div>
+ {/if}
+ {#if received.length}
+ <div>
+ <h1 class="text-secondary text-xl">Requests</h1>
- {#each received as { id, invoice, memo, requester: r }}
- <a href={`/${user.username}/receive/${id}`}>
- <div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
- <div class="flex">
- <div>
- <div class="flex">
- <Avatar user={r} size={20} />
- <div class="my-auto text-left">
- <p class="ml-1 text-lg break-words">{r.username}</p>
- <p class="ml-1 text-secondary">{memo}</p>
- </div>
- </div>
- </div>
- <div class="whitespace-nowrap my-auto ml-auto flex gap-2">
- <button class="rounded-full border py-2 px-4 font-bold hover:opacity-80 w-full"
- >Invoice</button
- >
- </div>
- </div>
- </div>
- </a>
- {/each}
- </div>
- {/if}
+ {#each received as { id, invoice, memo, requester: r }}
+ <a href={`/${user.username}/receive/${id}`}>
+ <div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
+ <div class="flex">
+ <div>
+ <div class="flex">
+ <Avatar user={r} size={20} />
+ <div class="my-auto text-left">
+ <p class="ml-1 text-lg break-words">{r.username}</p>
+ <p class="ml-1 text-secondary">{memo}</p>
+ </div>
+ </div>
+ </div>
+ <div class="whitespace-nowrap my-auto ml-auto flex gap-2">
+ <button
+ class="rounded-full border py-2 px-4 font-bold hover:opacity-80 w-full"
+ >Invoice</button
+ >
+ </div>
+ </div>
+ </div>
+ </a>
+ {/each}
+ </div>
+ {/if}
- {#if latest.length && user?.id === subject.id}
- <div class="relative">
- {#each latest as { content, pubkey, author, recipient }}
- {@const user = author.id === user.id ? recipient : author}
- <a href={`/${user.username}/messages`}>
- <div class="flex hover:bg-gray-100 p-4 rounded-2xl">
- <div class="my-auto">
- <Avatar {user} size={'20'} disabled={true} />
- </div>
- <div class="my-auto truncate">
- <div class="my-auto ml-1 text-lg font-bold">{user.username}</div>
- <div class="my-auto ml-1 text-secondary text-lg truncate">
- {content}
- </div>
- </div>
- </div>
- </a>
- {/each}
- </div>
- {/if}
+ {#if latest.length && user?.id === subject.id}
+ <div class="relative">
+ {#each latest as { content, pubkey, author, recipient }}
+ {@const user = author.id === user.id ? recipient : author}
+ <a href={`/${user.username}/messages`}>
+ <div class="flex hover:bg-gray-100 p-4 rounded-2xl">
+ <div class="my-auto">
+ <Avatar {user} size={"20"} disabled={true} />
+ </div>
+ <div class="my-auto truncate">
+ <div class="my-auto ml-1 text-lg font-bold">{user.username}</div>
+ <div class="my-auto ml-1 text-secondary text-lg truncate">
+ {content}
+ </div>
+ </div>
+ </div>
+ </a>
+ {/each}
+ </div>
+ {/if}
</div>
-
-<style>
- h1 {
- @apply mb-2;
- }
-</style>
diff --git a/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.js b/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.js
index 6182de17..ec4da865 100644
--- a/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.js
+++ b/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.js
@@ -1,12 +1,12 @@
-import { get } from '$lib/utils';
-import { error } from '@sveltejs/kit';
+import { get } from "$lib/utils";
+import { error } from "@sveltejs/kit";
export async function load({ params: { id } }) {
- try {
- let event = await get(`/event/${id}`);
- if (!event) throw error(500, 'Event not found');
- return { event };
- } catch (e) {
- throw error(500, e.message);
- }
+ try {
+ let event = await get(`/event/${id}`);
+ if (!event) throw error(500, "Event not found");
+ return { event };
+ } catch (e) {
+ throw error(500, e.message);
+ }
}
diff --git a/src/routes/(app)/[username]/(profile)/event/[id]/+page.svelte b/src/routes/(app)/[username]/(profile)/event/[id]/+page.svelte
index 85fc815a..74ce1067 100644
--- a/src/routes/(app)/[username]/(profile)/event/[id]/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/event/[id]/+page.svelte
@@ -1,7 +1,7 @@
<script>
- import { Event } from '$comp';
- export let data;
- let { event } = data;
+ import Event from "$comp/Event.svelte";
+ export let data;
+ let { event } = data;
</script>
<Event {event} />
diff --git a/src/routes/(app)/[username]/(profile)/followers/+page.svelte b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
index 56b3ba16..e087ad42 100644
--- a/src/routes/(app)/[username]/(profile)/followers/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
@@ -1,51 +1,52 @@
<script>
- import { t } from '$lib/translations';
- import { Avatar } from '$comp';
- import { browser } from '$app/environment';
- import VirtualScroll from 'svelte-virtual-scroll-list';
+ import { t } from "$lib/translations";
+ import Avatar from "$comp/Avatar.svelte";
+ import { browser } from "$app/environment";
+ import VirtualScroll from "svelte-virtual-scroll-list";
- export let data;
- let {
- subject: { followers }
- } = data;
+ export let data;
+ let {
+ subject: { followers },
+ } = data;
- let w;
+ let w;
</script>
<svelte:window bind:innerWidth={w} />
<div class="px-3 md:px-0 w-full md:w-[400px] mx-auto space-y-8">
- <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
- {$t('user.followers')}
- </h1>
+ <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
+ {$t("user.followers")}
+ </h1>
- {#if browser}
- {#if followers.length}
- <VirtualScroll data={followers} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}`}>
- <div
- class="flex border-b last:border-b-0 py-4 text-sm lg:text-lg text-secondary"
- :key={data.pubkey}
- >
- <div class="mb-auto mr-2">
- <div class="md:hidden">
- <Avatar size={12} user={data} disabled={true} />
- </div>
- <div class="hidden md:block">
- <Avatar size={20} user={data} disabled={true} />
- </div>
- </div>
+ {#if browser}
+ {#if followers.length}
+ <VirtualScroll data={followers} key="pubkey" let:data pageMode={true}>
+ <a href={`/${data.pubkey}`}>
+ <div
+ class="flex border-b last:border-b-0 py-4 text-sm lg:text-lg text-secondary"
+ :key={data.pubkey}
+ >
+ <div class="mb-auto mr-2">
+ <div class="md:hidden">
+ <Avatar size={12} user={data} disabled={true} />
+ </div>
+ <div class="hidden md:block">
+ <Avatar size={20} user={data} disabled={true} />
+ </div>
+ </div>
- <div class="w-full flex pb-1 text-black my-auto">
- <div>
- {data.display_name || ''} <span class="text-secondary">@{data.username}</span>
- </div>
- </div>
- </div>
- </a>
- </VirtualScroll>
- {:else}
- <div>No followers</div>
- {/if}
- {/if}
+ <div class="w-full flex pb-1 text-black my-auto">
+ <div>
+ {data.display_name || ""}
+ <span class="text-secondary">@{data.username}</span>
+ </div>
+ </div>
+ </div>
+ </a>
+ </VirtualScroll>
+ {:else}
+ <div>No followers</div>
+ {/if}
+ {/if}
</div>
diff --git a/src/routes/(app)/[username]/(profile)/follows/+page.svelte b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
index b238c3a7..e4363796 100644
--- a/src/routes/(app)/[username]/(profile)/follows/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
@@ -1,47 +1,51 @@
<script>
- import { t } from '$lib/translations';
- import { Avatar } from '$comp';
- import { browser } from '$app/environment';
- import VirtualScroll from 'svelte-virtual-scroll-list';
+ import { t } from "$lib/translations";
+ import Avatar from "$comp/Avatar.svelte";
+ import { browser } from "$app/environment";
+ import VirtualScroll from "svelte-virtual-scroll-list";
- export let data;
- let {
- subject: { follows }
- } = data;
- let w;
+ export let data;
+ let {
+ subject: { follows },
+ } = data;
+ let w;
</script>
<svelte:window bind:innerWidth={w} />
<div class="px-3 md:px-0 w-full md:w-[400px] mx-auto space-y-8">
- <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
- {$t('user.following')}
- </h1>
+ <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
+ {$t("user.following")}
+ </h1>
- {#if browser}
- {#if follows.length}
- <VirtualScroll data={follows} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}`}>
- <div class="flex py-4 text-sm lg:text-lg text-secondary" :key={data.pubkey}>
- <div class="mb-auto mr-2">
- <div class="md:hidden">
- <Avatar size={12} user={data} disabled={true} />
- </div>
- <div class="hidden md:block">
- <Avatar size={20} user={data} disabled={true} />
- </div>
- </div>
+ {#if browser}
+ {#if follows.length}
+ <VirtualScroll data={follows} key="pubkey" let:data pageMode={true}>
+ <a href={`/${data.pubkey}`}>
+ <div
+ class="flex py-4 text-sm lg:text-lg text-secondary"
+ :key={data.pubkey}
+ >
+ <div class="mb-auto mr-2">
+ <div class="md:hidden">
+ <Avatar size={12} user={data} disabled={true} />
+ </div>
+ <div class="hidden md:block">
+ <Avatar size={20} user={data} disabled={true} />
+ </div>
+ </div>
- <div class="w-full flex pb-1 text-black my-auto">
- <div>
- {data.display_name || ''} <span class="text-secondary">@{data.username}</span>
- </div>
- </div>
- </div>
- </a>
- </VirtualScroll>
- {:else}
- <div>No follows</div>
- {/if}
- {/if}
+ <div class="w-full flex pb-1 text-black my-auto">
+ <div>
+ {data.display_name || ""}
+ <span class="text-secondary">@{data.username}</span>
+ </div>
+ </div>
+ </div>
+ </a>
+ </VirtualScroll>
+ {:else}
+ <div>No follows</div>
+ {/if}
+ {/if}
</div>
diff --git a/src/routes/(app)/[username]/(profile)/request/+page.server.js b/src/routes/(app)/[username]/(profile)/request/+page.server.js
index e7ad6a8f..754c5805 100644
--- a/src/routes/(app)/[username]/(profile)/request/+page.server.js
+++ b/src/routes/(app)/[username]/(profile)/request/+page.server.js
@@ -1,15 +1,15 @@
-import { redirect } from '@sveltejs/kit';
-import { fd, auth, post } from '$lib/utils';
+import { redirect } from "@sveltejs/kit";
+import { fd, auth, post } from "$lib/utils";
export const actions = {
- create: async ({ cookies, params, request, url }) => {
- let form = await fd(request);
- let { id, requester } = await post('/requests', form, auth(cookies));
- throw redirect(307, `/${params.username}/request/${id}`);
- },
+ create: async ({ cookies, params, request, url }) => {
+ let form = await fd(request);
+ let { id, requester } = await post("/requests", form, auth(cookies));
+ throw redirect(307, `/${params.username}/request/${id}`);
+ },
- delete: async ({ cookies, request }) => {
- let form = await fd(request);
- let r = await post('/requests/delete', form, auth(cookies));
- }
+ delete: async ({ cookies, request }) => {
+ let form = await fd(request);
+ let r = await post("/requests/delete", form, auth(cookies));
+ },
};
diff --git a/src/routes/(app)/[username]/(profile)/request/+page.svelte b/src/routes/(app)/[username]/(profile)/request/+page.svelte
index 75117ff4..a07ee914 100644
--- a/src/routes/(app)/[username]/(profile)/request/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/request/+page.svelte
@@ -1,35 +1,35 @@
<script>
- import { t } from '$lib/translations';
- import { enhance } from '$app/forms';
- import { Icon } from '$comp';
+ import { t } from "$lib/translations";
+ import { enhance } from "$app/forms";
+ import Icon from "$comp/Icon.svelte";
- export let data;
+ export let data;
- let { subject, user } = data;
+ let { subject, user } = data;
</script>
<div class="container max-w-lg px-4 mx-auto mt-10 space-y-5">
- <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
- {$t('payments.requestAnInvoice')}
- </h1>
+ <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
+ {$t("payments.requestAnInvoice")}
+ </h1>
- <form action="?/create" method="POST" use:enhance class="space-y-5">
- <input type="hidden" name="requester_id" value={user.id} />
- <input type="hidden" name="recipient" value={subject.username} />
+ <form action="?/create" method="POST" use:enhance class="space-y-5">
+ <input type="hidden" name="requester_id" value={user.id} />
+ <input type="hidden" name="recipient" value={subject.username} />
- <textarea
- name="memo"
- placeholder={$t('payments.describeOrder')}
- class="w-full p-4 border rounded-xl h-48"
- />
+ <textarea
+ name="memo"
+ placeholder={$t("payments.describeOrder")}
+ class="w-full p-4 border rounded-xl h-48"
+ />
- <div class="w-full flex">
- <button
- type="submit"
- class="bg-black text-white border rounded-full px-6 py-2 font-bold mx-auto"
- >
- {$t('payments.submit')}
- </button>
- </div>
- </form>
+ <div class="w-full flex">
+ <button
+ type="submit"
+ class="bg-black text-white border rounded-full px-6 py-2 font-bold mx-auto"
+ >
+ {$t("payments.submit")}
+ </button>
+ </div>
+ </form>
</div>
diff --git a/src/routes/(app)/[username]/(profile)/request/sent/+page.svelte b/src/routes/(app)/[username]/(profile)/request/sent/+page.svelte
index 4995bfb2..ce5eb276 100644
--- a/src/routes/(app)/[username]/(profile)/request/sent/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/request/sent/+page.svelte
@@ -1,18 +1,21 @@
<script>
- import { scale } from 'svelte/transition';
- import { Icon } from '$comp';
+ import { scale } from "svelte/transition";
+ import Icon from "$comp/Icon.svelte";
- export let data;
- let { subject } = data;
+ export let data;
+ let { subject } = data;
</script>
<div class="container px-4 text-center mx-auto">
- <div class="flex w-full py-20 max-w-[200px] mx-auto" in:scale={{ start: 0.5 }}>
- <Icon icon="check" style="mx-auto" />
- </div>
- <h1 class="text-3xl md:text-4xl font-bold mb-6">Request sent</h1>
+ <div
+ class="flex w-full py-20 max-w-[200px] mx-auto"
+ in:scale={{ start: 0.5 }}
+ >
+ <Icon icon="check" style="mx-auto" />
+ </div>
+ <h1 class="text-3xl md:text-4xl font-bold mb-6">Request sent</h1>
</div>
<a href={`/${subject.username}`}>
- <div class="opacity-0 w-screen h-screen fixed top-24 left-0 z-50" />
+ <div class="opacity-0 w-screen h-screen fixed top-24 left-0 z-50" />
</a>